package com.songcha.module_mine.ui.adapter

import android.view.ViewGroup.MarginLayoutParams
import androidx.databinding.ViewDataBinding
import com.chad.library.adapter.base.BaseQuickAdapter
import com.chad.library.adapter.base.viewholder.BaseDataBindingHolder
import com.songcha.library_common.util.dp2px
import com.songcha.module_mine.R
import com.songcha.module_mine.bean.SystemMessageDataBean
import com.songcha.module_mine.databinding.MineItemMessageNotifyBinding

class MessageNotifyAdapter<DB:ViewDataBinding>(list:MutableList<SystemMessageDataBean.SystemMessageBean>):BaseQuickAdapter<SystemMessageDataBean.SystemMessageBean,BaseDataBindingHolder<DB>>(
    R.layout.mine_item_message_notify,list) {

    override fun convert(holder: BaseDataBindingHolder<DB>, item: SystemMessageDataBean.SystemMessageBean) {
        val db=holder.dataBinding as MineItemMessageNotifyBinding
        db.mineTvMsg.text=item.msg
        db.mineTvTitle.text=item.title
        if(holder.absoluteAdapterPosition==0 || holder.absoluteAdapterPosition==data.size){
            db.root.layoutParams=db.root.layoutParams.apply {
                this as MarginLayoutParams
                topMargin=12.dp2px()
                bottomMargin=12.dp2px()
            }
        }else{
            db.root.layoutParams=db.root.layoutParams.apply {
                this as MarginLayoutParams
                topMargin=0
                bottomMargin=0
            }
        }
    }


}